home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
objtools
/
tlline.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
205 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* tlline -
* Locate interesting edges in a set of triangles.
*
* Positive Z's are closer than Negative Z's.
*
* uses special functions:
* trinormal
* vplane
* flerp
* vlerp
* vdot
*
* Paul Haeberli - 1990
*/
#include "stdio.h"
#include "gl.h"
#include "device.h"
#include "vect.h"
float frand();
#define WSIZE (300)
#define ASPECT (3.0/2.0)
FILE *outf;
float myw;
/*
* GL output funcs
*
*/
int widthline(w)
float w;
{
myw = w;
}
int drawline(p0,p1)
vect *p0, *p1;
{
int iw;
iw = myw*400.0+frand();
if(iw<1)
iw = 1;
linewidth(iw);
bgnline();
v2f((float*)p0);
v2f((float*)p1);
endline();
}
/*
* PostScript output funcs
*
*/
int widthpsline(w)
float w;
{
pslinewidth(w);
}
int drawpsline(p0,p1)
vect *p0, *p1;
{
psline(outf,p0,p1);
}
/*
* Both output funcs
*
*/
int widthbothline(w)
float w;
{
widthline(w);
widthpsline(w);
}
int drawbothline(p0,p1)
vect *p0, *p1;
{
drawline(p0,p1);
drawpsline(p0,p1);
}
float frand2()
{
float v;
v = frand();
return v*v;
}
randsel()
{
float hf, sil, w, seg;
hf = 30.0*frand();
handsetwobble(hf,0.005*frand());
seg = 1.0/(2.0*hf);
handsetseglen(seg);
handsetdropout(0.1*frand());
hiddencolorthresh(0.3*frand());
sil = 0.03*frand2();
hiddensilwidth(sil/3.0,sil);
hiddenhalowidth(0.03*frand2());
w = 0.03*frand2();
hiddenfacewidths(w/3.0,w,w/2.0);
if(frand()>0.25)
hiddenextend(0.10*frand(),0.10*frand(),frand());
else
hiddenextend(0.0,0.0,0.0);
}
openps(name)
char *name;
{
/* open output PostScript file */
outf = fopen(name,"w");
if(!outf) {
fprintf(stderr,"tlline: can't open output file\n");
exit(1);
}
beginps(outf,3.0/2.0,-ASPECT,ASPECT,-1.0,1.0);
}
closeps()
{
endps();
fclose(outf);
}
main(argc,argv)
int argc;
char **argv;
{
int i;
if(argc<3) {
fprintf(stderr,"usage: tlline input.tl out.ps [-g]\n");
exit(1);
}
/* set up the parameters */
handsetwobble(50.0,0.0);
handsetwarp(1.0,0.0);
handsetdropout(0.0);
handsetseglen(0.1);
hiddencolorthresh(0.10);
hiddensilwidth(0.001,0.003);
hiddenhalowidth(0.003);
hiddenfacewidths(0.003,0.006,0.003);
hiddenextend(0.0,0.0,0.0);
if(argc>3) {
prefposition(0,(3*WSIZE)-1,50,50+(2*WSIZE)-1);
foreground();
winopen("tlline");
qdevice(LEFTMOUSE);
qdevice(MIDDLEMOUSE);
RGBmode();
gconfig();
deflinestyle(1,0x3030);
reshapeviewport();
ortho(-ASPECT,ASPECT,-1.0,1.0,-2.0,2.0);
rgb(1.0,1.0,1.0);
clear();
rgb(0.0,0.0,0.0);
/* make the hidden line picture */
openps(argv[2]);
hiddenline(argv[1],drawbothline,widthbothline);
closeps();
} else {
/* make the hidden line picture */
openps(argv[2]);
hiddenline(argv[1],drawpsline,widthpsline);
closeps();
}
/* close the output file */
exit(0);
}